PACKAGE BODY Application IS

   PROCEDURE Petrinet_Analysis IS
      Selected_File_Name  : Ada.Strings.Unbounded.Unbounded_String;
      Nb_Places, Nb_Trans : Integer := 0;
      Handler             : Xml_Readers.Handler;
      Blank               : Character;
   BEGIN

      --selection du fichier
      Selected_File_Name := Console_Interface.File_Chooser (Dyn_Str.To_String (Xml_Path), "*.xml");
      Console_Interface.Clear;

      --Comptage du nombre de place et du nombre de transitions
      Xml_Readers.Load (Handler, Dyn_Str.To_String (Selected_File_Name), "petrinet");

      WHILE Xml_Readers.Has_Next_Element (Handler) LOOP
         Xml_Readers.Next_Element (Handler);
         IF Xml_Readers.Current_Element (Handler) = "place" THEN
            Nb_Places := Nb_Places + 1;
         END IF;
         IF Xml_Readers.Current_Element (Handler) = "transition" THEN
            Nb_Trans := Nb_Trans + 1;
         END IF;
      END LOOP;
      Xml_Readers.Close (Handler);

      -- Declaration et construction du RDP


      DECLARE
         PACKAGE Rdp IS NEW Petrinets (Nb_Places, Nb_Trans);
         P1                 : Rdp.Petrinet;
      BEGIN

         NULL;
         P1 := Rdp.Xml_Build (Dyn_Str.To_String (Selected_File_Name), "petrinet");

         Rdp.Put (P1);

         Ada.Text_IO.Put_Line ("- Le RDP est compose de " & Integer'Image (Rdp.Get_Nb_Place (P1))
                               & " place(s) et de "& Integer'Image (Rdp.Get_Nb_Transition (P1))&" transition(s)");
         Ada.Text_IO.Put_Line ("- Le RDP est vivant : " & Boolean'Image (Rdp.Is_Live (P1)));
         Ada.Text_IO.Put_Line ("- Le RDP est quasi-vivant : " & Boolean'Image (Rdp.Is_L1_Live (P1)));
         Ada.Text_IO.Put_Line ("- Le RDP est borne : " & Boolean'Image (Rdp.Is_Bounded (P1)));
         Ada.Text_IO.New_Line;
         Ada.Text_Io.Put_Line ("Commande terminee... [entrer]");
         Ada.Text_IO.Get_Immediate (Blank);
      END;


   END Petrinet_Analysis;


   PROCEDURE Test_Suite IS
      Blank               : Character;
   BEGIN
      Test_Cases_Mainsuite.Set_Up;
      Test_Cases_Mainsuite.Run;
      Test_Cases_Mainsuite.Tear_Down;
      Ada.Text_Io.Put_Line ("Fin des tests... [entrer]");
      Ada.Text_IO.Get_Immediate (Blank);
   END Test_Suite;

   PROCEDURE About IS
      Blank               : Character;
   BEGIN
      Console_Interface.Put_Title ("A PROPOS");
      Ada.Text_IO.New_Line;
      Console_Interface.Put_Sub_Title ("Equipe de realisation [M1-TIIL] :");
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Stephane LUCAS");
      Ada.Text_IO.Put_Line ("Sandra PARLANT");
      Ada.Text_IO.Put_Line ("Glenn CAVARLE");
      Ada.Text_IO.Put_Line ("Samuel COLIN");
      Ada.Text_IO.New_Line;
      Console_Interface.Put_Sub_Title ("Description :");
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Application d'analyse de reseau de petri au format XML.");
      Ada.Text_IO.Put_Line ("Application realise en ADA.");
      Ada.Text_IO.Put_Line ("Fevrier 2012.");
      Ada.Text_IO.New_Line;
      Ada.Text_Io.Put_Line ("[entrer]");
      Ada.Text_IO.Get_Immediate (Blank);
   END About;

END Application;
